package com.enjoy.rpc;

import com.enjoy.rpc.rpc.RpcClientFrame;
import com.enjoy.rpc.rpc.ServerSubcri;
import com.enjoy.rpc.service.SendSms;
import com.enjoy.rpc.service.StockService;
import com.enjoy.rpc.vo.UserInfo;

import java.io.IOException;

/**
 * Created by HP on 2019/7/3.
 */
public class RpcClient {
    public static void main(String[] args) throws IOException {
        UserInfo userInfo
                = new UserInfo("Mark", "Mark@xiangxue.com");
        String addrs = ServerSubcri.findService(SendSms.class.getName());
        if ("F".equals(addrs)) {
            return;
        }
        System.out.println(addrs + "*******88");
        String[] addrInfo = addrs.split(":");
        SendSms sendSms = RpcClientFrame.getRemoteProxyObj(SendSms.class,
                addrInfo[0], Integer.parseInt(addrInfo[1]));
        System.out.println("Send mail: " + sendSms.sendMail(userInfo));

//        StockService stockService = RpcClientFrame.getRemoteProxyObj(StockService.class, "127.0.0.1", 9190);
//        stockService.deduceStock("A001", 10);
    }


}
